
class Stack:
    '''栈: 先进后出'''
    def __init__(self):
        self._items = []

    def push(self, item):
        '''进栈'''
        self._items.append(item)

    def pop(self):
        '''出栈'''
        self._items.pop()

    def travel(self):
        '''遍历'''
        for i in self._items:
            print(i)


my_stack = Stack()
my_stack.push(1)
my_stack.push(2)
my_stack.push(3)
my_stack.travel()

# 出栈
my_stack.pop()
my_stack.travel()

